/**
 * Product 业务逻辑实现类
 * @author yanwl
 * @date 2014-08-20
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Product;
import com.chnbst.bstyun.model.vo.ProductIndustryVo;
import com.chnbst.bstyun.service.ProductService;

@Transactional
@Service
public class ProductServiceImpl extends BaseService implements ProductService {
	
	//声明日志对象 logback
	private final static Logger logger = LoggerFactory.getLogger(ProductServiceImpl.class);
	private final static String nameSpace = "com.chnbst.bstyun.mapper.ProductMapper";
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean deleteProduct(Integer productId) {
		return DaoHelper.delete(nameSpace, "deleteProduct", productId);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertProduct(Product product) {
		return DaoHelper.insert(nameSpace, "insertProduct", product);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateProduct(Product product) {
		return DaoHelper.update(nameSpace, "updateProduct", product);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Product selectProductByProductId(Integer productId) {
		return (Product)DaoHelper.query(nameSpace, "selectProductByProductId", productId);
	}
	
	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<Product> selectProducts(Map<String, Object> map) {
		return (List<Product>)DaoHelper.list(nameSpace, "selectProducts", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public ProductIndustryVo selectProductIndustryVoByProductId(Integer productId) {
		return (ProductIndustryVo)DaoHelper.query(nameSpace, "selectProductIndustryVoByProductId", productId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@SuppressWarnings("unchecked")
	@Override
	public List<Product> selectAllProducts(Map<String, Object> map) {
		return (List<Product>) DaoHelper.list(nameSpace, "selectAllProducts", map);
	}
}
